//
// Created by liu on 2021/1/29.
//

#ifndef ITEA_DET_DARKNET_H
#define ITEA_DET_DARKNET_H

#include <vector>
#include <fstream>
#include <sstream>
#include <iostream>
#include <opencv2/dnn.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/objdetect.hpp>

#include "config.h"


using namespace std;
using namespace  cv;
namespace alg{

    class DarknetDet {
    public:
        DarknetDet(int w, int h);
        cv::dnn::Net initnet();
        int detect(unsigned char* image,vector<DetObjectStr>& boundRect) ;

    private:
        std::vector<cv::String> getOutputsNames(const cv::dnn::Net& net);
        void postprocess(Mat& frame, const vector<Mat>& out ,  vector<DetObjectStr> &boundRect);
        vector<cv::String>class_names;// Class Name
        float confThreshold; // Confidence threshold
        float nmsThreshold;  //Non - maximum suppression threshold
        int inpWidth;        // Width of network's input image
        int inpHeight;       // Height of network's input image
        int _image_height;
        int _image_width;
        cv::dnn::Net _net;
    };

}





#endif //ITEA_DET_DARKNET_H
